<template>
  <div>
    <p>
      <input type="text" placeholder="用户名" v-model="username" />
    </p>
    <p>
      <input type="text" placeholder="密码" v-model="pwd" />
    </p>
    <p>
      <button @click="loginFn">登录</button>
    </p>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      username: '',
      pwd: ''
    }
  },
  methods: {
    loginFn() {
      if (this.username && this.pwd) {
        // 如上都表示非空
        // 01: 将用户信息存到本地的localStorage
        localStorage.setItem('username', this.username)
        // 02: 跳转到首页
        this.$router.push('/home')
      }
    }
  }
}
</script>
<style scoped>
</style>